using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Net35.Xrm.Sdk
{
	[Serializable]
	public class DataCollection<T> : Collection<T>
	{
		internal DataCollection()
		{
		}
		internal DataCollection(IList<T> list)
		{
			this.AddRange(list);
		}
		public void AddRange(params T[] items)
		{
			if (items != null)
			{
				this.AddRange((IEnumerable<T>)items);
			}
		}
		public void AddRange(IEnumerable<T> items)
		{
			if (items != null)
			{
				foreach (T current in items)
				{
					base.Add(current);
				}
			}
		}
		public T[] ToArray()
		{
			T[] array = new T[base.Count];
			base.CopyTo(array, 0);
			return array;
		}
	}
	[Serializable]
	public abstract class DataCollection<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
	{
		private IDictionary<TKey, TValue> _innerDictionary = new Dictionary<TKey, TValue>();
		private bool _isReadOnly;
		public virtual TValue this[TKey key]
		{
			get
			{
				return this._innerDictionary[key];
			}
			set
			{
				this.CheckIsReadOnly();
				this._innerDictionary[key] = value;
			}
		}
		public int Count
		{
			get
			{
				return this._innerDictionary.Count;
			}
		}
		public ICollection<TKey> Keys
		{
			get
			{
				return this._innerDictionary.Keys;
			}
		}
		public ICollection<TValue> Values
		{
			get
			{
				return this._innerDictionary.Values;
			}
		}
		public virtual bool IsReadOnly
		{
			get
			{
				return this._isReadOnly;
			}
			internal set
			{
				this._isReadOnly = value;
			}
		}
		protected internal DataCollection()
		{
		}
		public void Add(KeyValuePair<TKey, TValue> item)
		{
			this.CheckIsReadOnly();
			this._innerDictionary.Add(item);
		}
		public void AddRange(params KeyValuePair<TKey, TValue>[] items)
		{
			this.CheckIsReadOnly();
			this.AddRange(items);
		}
		public void AddRange(IEnumerable<KeyValuePair<TKey, TValue>> items)
		{
			if (items != null)
			{
				this.CheckIsReadOnly();
				ICollection<KeyValuePair<TKey, TValue>> innerDictionary = this._innerDictionary;
				foreach (KeyValuePair<TKey, TValue> current in items)
				{
					innerDictionary.Add(current);
				}
			}
		}
		public void Add(TKey key, TValue value)
		{
			this.CheckIsReadOnly();
			this._innerDictionary.Add(key, value);
		}
		public void Clear()
		{
			this.CheckIsReadOnly();
			this._innerDictionary.Clear();
		}
		public bool Contains(TKey key)
		{
			return this._innerDictionary.ContainsKey(key);
		}
		public bool Contains(KeyValuePair<TKey, TValue> key)
		{
			return this._innerDictionary.Contains(key);
		}
		public bool TryGetValue(TKey key, out TValue value)
		{
			return this._innerDictionary.TryGetValue(key, out value);
		}
		public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
		{
			this._innerDictionary.CopyTo(array, arrayIndex);
		}
		public bool ContainsKey(TKey key)
		{
			return this._innerDictionary.ContainsKey(key);
		}
		public bool Remove(TKey key)
		{
			this.CheckIsReadOnly();
			return this._innerDictionary.Remove(key);
		}
		public bool Remove(KeyValuePair<TKey, TValue> item)
		{
			this.CheckIsReadOnly();
			return this._innerDictionary.Remove(item);
		}
		internal void SetItemInternal(TKey key, TValue value)
		{
			this._innerDictionary[key] = value;
		}
		internal void ClearInternal()
		{
			this._innerDictionary.Clear();
		}
		internal bool RemoveInternal(TKey key)
		{
			return this._innerDictionary.Remove(key);
		}
		private void CheckIsReadOnly()
		{
			if (this.IsReadOnly)
			{
				throw new InvalidOperationException("The collection is read-only.");
			}
		}
		public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
		{
			return this._innerDictionary.GetEnumerator();
		}
		IEnumerator IEnumerable.GetEnumerator()
		{
			return this._innerDictionary.GetEnumerator();
		}
		private static IEnumerable<Type> GetKnownParameterTypes()
		{
			return KnownTypesProvider.RetrieveKnownValueTypes();
		}
	}
}
